<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <canvas id="canvas" style="border: 1px solid #aaa; display: block; margin: 50px auto;">
        当前浏览器不支持Canvas，请更换浏览器
    </canvas>
    <script>
        window.onload = function () {
            var canvas = document.getElementById("canvas");

            canvas.width = 800;
            canvas.height = 800;

            var context = canvas.getContext("2d");

            context.fillStyle = 'red';
            context.strokeStyle = '#058';
            context.lineWidth = 5;

            // a c e
            // b d f
            // 0 0 1

            //a,d 水平、垂直缩放
            //b,c 水平、垂直倾斜
            //e,f 水平、垂直位移

            context.save();
            context.transform(2, -0.2, -0.2, 1.5, 50, 100);
            context.setTransform(1, 0, 0, 1, 100, 100); //忽略之前的所有transform，以单位矩阵开始设置
            context.fillRect(50, 50, 300, 300);
            context.strokeRect(50, 50, 300, 300);
            context.restore();
        }
    </script>
</body>
</html>